<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Home Chart Dashboard</title>
    <style>
        .home-chart-container {
            overflow-y: auto;
            height: 255px;
            display: flex;
            flex-direction: column;
            align-items: center;
            background-color: transparent;
        }

        .home-recstat-title {
            width: 100%;
            height: 40px;
            line-height: 40px;
            background-color: transparent;
            color: white;
            text-align: center;
            font-size: 18px;
            margin-bottom: 20px;
        }

        .home-recstat-container {
            width: 100%;
            max-width: 1200px;
            height: 160px;
            display: flex;
            justify-content: center;
            align-items: center;
            background: transparent;
            padding: 0 10px;
        }

        .home-recstat-container-item {
            height: 100%;
            flex: 1;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            color: white;
        }

        .splitline {
            width: 2px;
            height: 60px;
            background-color: rgba(120, 120, 120, 0.6);
            margin: 0 5px;
        }

        .home-stat-item {
            width: 100%;
            text-align: center;
        }

        .home-stat-item-title {
            font-size: 1rem;
            margin-bottom: 10px;
        }

        .home-stat-item-value {
            font-family: "lccd";
            font-size: 2.5rem;
            color: #FFA72E;
        }

        .item {
            width: 100%;
            padding: 0.2rem 0;
        }
    </style>
</head>
<body>
<div class="home-chart-container">
    <div class="home-recstat-title">执法监督</div>
    <div class="home-recstat-container" id="stat-bands"></div>
</div>

<script>
    const mockData = {
        statBands: [
            {title: "执法队员", value: 267},
            {title: "劝告程序", value: 2169},
            {title: "一般程序", value: 1456},
            {title: "简易程序", value: 1088}
        ]
    };

    function renderStatBands() {
        const container = document.getElementById("stat-bands");
        container.innerHTML = "";
        mockData.statBands.forEach((item, index) => {
            const itemDiv = document.createElement("div");
            itemDiv.className = "home-recstat-container-item";
            itemDiv.innerHTML = `
                    <div class="item">
                        <div class="home-stat-item home-stat-item-title">${item.title}</div>
                    </div>
                    <div class="item">
                        <div class="home-stat-item home-stat-item-value">${item.value}</div>
                    </div>
                `;
            itemDiv.onclick = () => goToRecList(item.title);
            container.appendChild(itemDiv);

            if (index < mockData.statBands.length - 1) {
                const splitline = document.createElement("div");
                splitline.className = "splitline";
                container.appendChild(splitline);
            }
        });
    }

    function goToRecList(bizName) {
        alert(`Navigating to Rec List for ${bizName}`);
    }


    document.addEventListener("DOMContentLoaded", () => {
        renderStatBands();

        const container = document.querySelector('.home-chart-container');
        const img = new Image();
        img.src = "http://61.134.60.13:38080/linglong-api/files/iconfont/image/YmFja2dyb3VuZA.png";
        img.height = "255rem";
        img.onload = () => {
            console.log("Background image loaded successfully!");
            container.style.backgroundImage = `url("http://61.134.60.13:38080/linglong-api/files/iconfont/image/YmFja2dyb3VuZA.png")`;
        };
        img.onerror = () => {
            console.error("Failed to load background image 'back-img'. Check the file path or accessibility.");

            container.style.backgroundColor = "gray";
            container.style.backgroundImage = "none";
        };
    });
</script>
</body>
</html>
